﻿Imports System.Resources
Imports System.IO
Public Class frmEntryChoixTypeObs
    Public bTypeSite As String = ""
    Dim locationsFile As String
    Private rm As New ResourceManager(GetType(frmEntryChoixTypeObs))

    Private Sub btnSuivant_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSuivant.Click
        Try
            'Intialisation des données saisie pécédement
            frmEntryProtocol.maIndexStation = Nothing
            frmEntryProtocol.monIdZoneEtude = Nothing
            frmEntryProtocol.maZoneEtude = Nothing

            If rb_ObserPonct.Checked = True Then
                frmEntryFin.typeObs = "prospection"
                bTypeSite = "Ponctuel"
                frmEntryFin.dEntryStep = 2.1
                frmEntryGPS.Show()
                Me.Hide()
            End If
            If rb_SuiviSite.Checked = True Then
                bTypeSite = "Suivi"
                frmEntryFin.typeObs = "monitoring"
                'Test de la liste des sites
                Try
                    Dim i As Integer
                    'Gère le chargement de la liste de sites
                    ' recuperer le nom de fichier sites
                    locationsFile = DirectCast(frmEntryChoixProtocol.olistProtocoles.Protocols(frmEntryChoixProtocol.selectedProtocolId), clsProtocol).monitoringFile
                    ' verifier si le fichier n'est pas chargé ou si on doit charger un fichier différent
                    If frmEntryChoixSite.lstViewSite.Items.Count = 0 Or locationsFile <> frmEntryChoixSite.listSiteFileName Then
                        ' charger la liste de sites
                        Cursor.Current = Cursors.WaitCursor()
                        i = LoadFile(FormMain.NSDossier & locationsFile, frmEntryChoixSite.lstViewSite)
                        frmEntryChoixSite.listSiteFileName = locationsFile
                        ArrangeListView(frmEntryChoixSite.lstViewSite, 1)
                        Cursor.Current = Cursors.Default
                        If i <= 2 Then
                            MsgBox(DirectCast(My.Resources.Images.errorEmptyFile, String) & ":" & FormMain.NSDossier & locationsFile, MsgBoxStyle.Critical, "Pocket eRelevé")
                            Exit Sub
                        End If
                    End If
                    frmEntryChoixSite.Show()
                    frmEntryFin.dEntryStep = 2.2
                    Me.Hide()
                Catch ex As Exception
                    Cursor.Current = Cursors.Default
                    MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Pocket eRelevé")
                    Exit Sub
                End Try
            End If
        Catch ex As Exception
            MsgBox(DirectCast(My.Resources.Images.errorOnSave, String) & " : " & ex.Message, MsgBoxStyle.Exclamation, "Pocket eRelevé")
        End Try
    End Sub

    Private Sub btnMenu_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click
        frmEntryFin.dEntryStep = 0
        FormMain.Show()
        Me.Hide()
    End Sub

    Private Sub frmChoixLocalisation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        rb_ObserPonct.Checked = True
    End Sub

    Private Sub btnDataShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDataShow.Click
        Dim succed As Boolean = frmDataObsTable.initDataGrid(oProtocolsCurrentListObs, frmEntryChoixProtocol.selectedProtocolId)
        If succed Then
            previous = Me.Name
            frmDataObsTable.Show()
            Me.Hide()
        End If
    End Sub

    Private Sub CtlLightGPSTrack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmUtilityTracks.Show()
        Me.Hide()
    End Sub

    Private Sub btnRetour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetour.Click
        frmEntryChoixProtocol.Show()
        Me.Hide()
    End Sub

    Private Sub frmEntryChoixTypeObs_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.GotFocus
        previous = Me.Name
    End Sub
End Class